﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CommonLib;
using System.Data.SqlClient;

namespace YouErYuanBLL
{
    public class JiaZhangBLL
    {

        /// <summary>
        /// 验证手机号是否存在
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        public int CheckPhone(string phone)
        {
            string sql = "SELECT COUNT(1) FROM [dbo].[T_JiaZhang] where [phone]=@phone";
            object obj = SQLHepler.GetSingleValue(sql, new System.Data.SqlClient.SqlParameter("@phone", phone));
            if (obj.GetType() == typeof(System.DBNull))
            {
                return 0;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }

        /// <summary>
        /// 修改家长密码、手机号
        /// </summary>
        /// <param name="jzId">家长id</param>
        /// <param name="phone"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public int UpdateJiaZ(string jzId, string phone, string pwd)
        {
            string sql = "update [dbo].[T_JiaZhang] set [phone]=@phone,[password]=@pwd where [jzId]=@jzId";
            SqlParameter[] parames = {
                new SqlParameter("@jzId",jzId),
                new SqlParameter("@phone",phone),
                new SqlParameter("@pwd",pwd),
            };
            return SQLHepler.ExecuteSql(sql, parames);
        }

    }
}
